package org.michaelrenaud.pathfinder.client.core.app.combat;

import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.annotations.NameToken;
import com.gwtplatform.mvp.client.annotations.ProxyEvent;

import org.michaelrenaud.pathfinder.client.place.NameTokens;
import com.gwtplatform.mvp.client.proxy.ProxyPlace;
import com.google.inject.Inject;
import com.google.gwt.event.shared.EventBus;
import com.gwtplatform.mvp.client.proxy.RevealContentEvent;
import org.michaelrenaud.pathfinder.client.core.app.AppPresenter;
import org.michaelrenaud.pathfinder.client.event.CharacterChangeEvent;
import org.michaelrenaud.pathfinder.client.event.CharacterChangeEvent.CharacterChangeHandler;
import org.michaelrenaud.pathfinder.shared.model.Character;
import org.michaelrenaud.pathfinder.shared.model.StatBlock;

public class CombatPresenter extends Presenter<CombatPresenter.MyView, CombatPresenter.MyProxy> implements CharacterChangeHandler {

	public interface MyView extends View {
		void setCharacter(Character character, StatBlock statBlock);
	}

	@ProxyCodeSplit	@NameToken(NameTokens.combat)
	public interface MyProxy extends ProxyPlace<CombatPresenter> {}

	@Inject
	public CombatPresenter(final EventBus eventBus, final MyView view, final MyProxy proxy) {
		super(eventBus, view, proxy);
	}

	@Override
	protected void revealInParent() {
		RevealContentEvent.fire(this, AppPresenter.TYPE_RevealContent, this);
	}

	@Override
	protected void onBind() {
		super.onBind();
	}

	@ProxyEvent	@Override
	public void onCharacterChange(CharacterChangeEvent event) {
		getView().setCharacter(event.getCharacter(), event.getStatBlock());
	}
}
